package com.dao;

import com.model.DeviceBox;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.List;

@Repository
public interface DeviceBoxMapper {

    int insertSelective(DeviceBox record);

    int deleteByPrimaryKey(Long id);

    int deleteByDeviceId(Long deviceId);


//    int insert(DeviceBox record);

    int updateByPrimaryKeySelective(DeviceBox record);


    //    int updateByPrimaryKey(DeviceBox record);

    DeviceBox selectByPrimaryKey(Long id);

    List<DeviceBox> selectByDeviceId(Long deviceId);

    List<DeviceBox> selectAll(DeviceBox deviceBox);

    DeviceBox selectBoxByDeviceIdAndBoxTypeAndBoxNum(@Param("deviceId") Long deviceId,@Param("boxType")  Integer boxType,@Param("boxNum")  String boxNum);

    int deceaseStoreByBoxId(@Param("id") Long id,@Param("stock") Integer stock,@Param("buyQuantity") Integer buyQuantity);

    DeviceBox selectIdleRentBoxByDeviceIdLimtOne(@Param("deviceId")Long deviceId,@Param("boxType") Integer boxType);

    Integer updateByPrimaryKey(DeviceBox box);

    int deceaseByDeviceIdAndBoxTypeAndBoxNum(@Param("deviceId") Long deviceId,@Param("boxType") Integer boxType,@Param("boxNum") String boxNum);

    int inceaseByDeviceIdAndBoxTypeAndBoxNum(@Param("deviceId") Long deviceId,@Param("boxType") Integer boxType,@Param("boxNum") String boxNum);


    DeviceBox selectBoxByDeviceIdAndProductIdHasStock(@Param("deviceId")Long deviceId,@Param("productId") Long productId);

    DeviceBox selectBoxByDeviceIdAndProductIdNoStock(@Param("deviceId")Long deviceId,@Param("productId") Long productId);

    int countNoStock(@Param("deviceId")Long deviceId);

    DeviceBox selectBoxByDeviceIdAndProductId(@Param("deviceId")Long deviceId,@Param("productId") Long productId);

    DeviceBox selectBoxByDeviceIdAndTypeProductId(@Param("deviceId")Long deviceId, @Param("productId") Long productId);

    int unifyProductFackPrice(@Param("deviceId")Long deviceId,@Param("productId") long productId,@Param("factPrice")BigDecimal factPrice);



}